#ifndef COUNTDOWNWIDGET_H
#define COUNTDOWNWIDGET_H

#include <QDialog>
#include <QTimer>
#include <QCloseEvent>

QT_BEGIN_NAMESPACE
namespace Ui { class CountdownWidget; }
QT_END_NAMESPACE

class CountdownWidget : public QDialog
{
    Q_OBJECT

public:
    CountdownWidget(QWidget *parent = nullptr);
    ~CountdownWidget();

    enum Button
    {
        Button_Ok=0,
        Button_Cancel
    };
    Q_ENUM(Button)

    bool isOk();
    void setMessageText(QString str);
    void setCountdownTotalTime(int t);
    void setCountdownInterval(int t);
    void startCountdownTimer(int t);
    void setButtonHide(CountdownWidget::Button btn);
    void setCloseEnable(bool sw);

private slots:
    void on_pushButton_cancel_clicked();
    void on_pushButton_ok_clicked();

private:
    Ui::CountdownWidget *ui;
    bool is_ok = false;
    QTimer* timer_countdown;
    double msgbox_time_;
    int totalTime;
    int interval;
    bool closeEnable = true;
    void closeEvent(QCloseEvent *event);

public slots:
    void count_time();
};
#endif // COUNTDOWNWIDGET_H
